//
//  AppDelegate.swift
//  WeChatDemo
//
//  Created by YJH on 2025/5/6.
//

import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()

        let rootViewController = makeTabController()
        window?.rootViewController = rootViewController
        
        return true
    }
    
    private func makeTabController() -> UITabBarController {
        let homeVC = HomeViewController()
        homeVC.tabBarItem.title = "微信"
        homeVC.tabBarItem.image = UIImage(named: "home")?.withRenderingMode(.alwaysOriginal)
        let contactVC = ContactViewController()
        contactVC.tabBarItem.title = "联系人"
        contactVC.tabBarItem.image = UIImage(named: "home")?.withRenderingMode(.alwaysOriginal)
        let exploreVC = ExploreViewController()
        exploreVC.tabBarItem.title = "发现"
        exploreVC.tabBarItem.image = UIImage(named: "home")?.withRenderingMode(.alwaysOriginal)
        let mainVC = MineViewController()
        mainVC.tabBarItem.title = "我的"
        mainVC.tabBarItem.image = UIImage(systemName: "trash.square.fill")
        let naviMain = UINavigationController(rootViewController: mainVC)
        let controller = UITabBarController()
        controller.setViewControllers([
            homeVC,
            contactVC,
            exploreVC,
            naviMain
        ], animated: false)
        controller.selectedIndex = 3
        return controller
    }

}
